<template>
  <div>
    <div class="markdown-highlight" v-html="markdownValue" v-highlight></div>
  </div>
</template>

<script>
import highlight from "../config/highlight";
export default {
  props: {
    value: {
      default: "",
    },
  },
  name: "easy-highlight",
  data() {
    return {};
  },
  computed: {
    markdownValue() {
      return this.value;
    },
  },
  mounted() {},

  methods: {},
};
</script>

<style lang="scss">
.markdown-highlight {
  padding: 20px;
}
.markdown-highlight pre * {
  font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace !important;
  line-height: 26px;
  font-size: 18px;
  box-sizing: border-box;
}

// 侧边行号 - 圆点
.markdown-highlight pre {
  width: 100%;
  overflow-x: auto;
  margin: 10px 0;
  border-radius: 4px;
  position: relative;
  margin-bottom: 24px;
  overflow: hidden;
  font-size: 16px;
  position: relative;
  box-sizing: border-box;
  background: #222832 !important;
  padding-top: 40px;
  box-shadow: rgba(0, 0, 0, 0.5) 0px 2px 10px;

  &::before {
    content: " ";
    position: absolute;
    border-radius: 2px;
    background: #ff5f56;
    width: 10px;
    height: 10px;
    top: 2px;
    left: 10px;
    margin-top: 12px;
    -webkit-box-shadow: 20px 0 #ffbd2e, 40px 0 #27c93f;
    box-shadow: 20px 0 #ffbd2e, 40px 0 #27c93f;
    z-index: 3;
  }
  &::after {
    content: attr(lang);
    position: absolute;
    right: 10px;
    top: 2px;

    color: #9e9e9e;
    font-size: 16px;
    line-height: 32px;
  }
}
// 行号
// .markdown-highlight .pre-numbering {
//   position: absolute;
//   top: 35px;
//   left: 0;
//   min-width: 20px;
//   height: 100%;
//   padding: 15px 5px 12px 5px;
//   border-right: 2px solid #323641;
//   background-color: #222832;
//   font-size: 16px;
// }
// .markdown-highlight .pre-numbering li {
//   min-width: 25px;
//   list-style: none;
//   font-family: Menlo, monospace;
//   color: #9e9e9e;
//   margin: 0;
//   text-align: center;
//   line-height: 27px !important;
//   font-size: 18px;
// }
.markdown-highlight .hljs {
  background-color: #222832;
}

// 表格
.markdown-highlight tr,
.markdown-highlight td,
.markdown-highlight table,
.markdown-highlight th {
  border: 1px solid #dfe2e5;
  padding: 6px 13px;
}
.markdown-highlight table {
  overflow: auto;
  border-spacing: 0;
  border-collapse: collapse;
}
.markdown-highlight table tr:nth-child(2n) {
  background: #f6f8fa;
}

// code样式
.markdown-highlight pre code {
  padding: 2px 4px;
  padding: 15px 20px 30px 20px !important;
  margin: 0;
  font-size: 18px;
  background-color: #222832 !important;
  border-radius: 3px;
  color: #abb2bf;
  border-top: 1px solid #323641;
}

.markdown-highlight li {
  margin-left: 30px;
}
.markdown-highlight ul li {
  list-style-type: disc;
}
.markdown-highlight ol li {
  list-style-type: decimal;
}
// 设置 水平线样式
.markdown-highlight hr {
  height: 4px;
  padding: 0;
  margin: 24px 0;
  background-color: #e1e4e8;
  border: 0;
}
.markdown-highlight a {
  text-decoration: none;
  color: #4e8af3 !important;
  font-weight: 600;
  margin: 0 3px;
  &:hover {
    text-decoration: underline;
    color: #4e8af3;
  }
}

.markdown-highlight p {
  color: #24292e;
}

.markdown-highlight p a {
  text-decoration: none;
  color: #4e8af3 !important;
  font-weight: 600;
  margin: 0 3px;

  &::before {
    content: "转到 : ";
  }
  &:hover {
    text-decoration: underline;
    color: #4e8af3;
  }
}

.markdown-highlight img {
  max-height: 200px;
  width: auto;
  margin: auto;
  display: block;
}

.markdown-highlight strong {
  font-weight: bold;
}
.markdown-highlight em {
  font-style: italic;
}

.markdown-highlight blockquote {
  padding: 10px 20px;
  position: relative;
  margin: 10px 5px;
  background: #f2f7fb;

  &::before {
    content: "";
    width: 5px;
    height: 100%;
    position: absolute;
    left: 0;
    top: 0;
    background: #dce6f0;
  }
}

.markdown-highlight mark {
  background: #4e8af3;
  padding: 0 3px;
}

.markdown-highlight * {
  letter-spacing: 1.5px;
  line-height: 1.8em;
  -webkit-text-size-adjust: 100%;
  word-break: break-all;
  text-align: justify;
  // font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
  //   "Courier New", monospace !important;
}

.markdown-highlight h1,
.markdown-highlight h2,
.markdown-highlight h3,
.markdown-highlight h4,
.markdown-highlight h5,
.markdown-highlight h6 {
  padding: 15px 0;
  border-bottom: 1px solid #eaecef;
  margin: 10px 0;
}
// 对齐方式
.markdown-highlight .hljs-center {
  text-align: center;
}
.markdown-highlight .hljs-left {
  text-align: left;
}
.markdown-highlight .hljs-right {
  text-align: right;
}

/*滚动条样式*/
.markdown-highlight code::-webkit-scrollbar {
  width: 6px;
  height: 5px;
}
.markdown-highlight code::-webkit-scrollbar-thumb {
  border-radius: 8px;
  background: rgba(170, 170, 170, 0.5);
}
.markdown-highlight code::-webkit-scrollbar-track {
  border-radius: 0;
  background: #323641;
}
</style>
